import { action, observable, computed } from "mobx";

export class ChatBot {
  @observable.deep info = sessionStorage.getItem("chatbotInfo")
    ? JSON.parse(sessionStorage.getItem("chatbotInfo"))
    : {
      chatbotId: 'Not Found',
      nickname: 'Not Found',
      theme: 'blue'
    }

  @action setInfo(val) {
    // action更新用户信息
    this.info = Object.assign(this.info, val)
    sessionStorage.setItem("chatbotInfo", JSON.stringify(this.info))
    sessionStorage.setItem("access_token", this.info.token)
  }
}


export default new ChatBot();